package com.qf.team2.netdisc.common.util;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;


public class FileUtil {
    public static void downloadFile(HttpServletResponse response,String fileName,String fileUrl){
        response.setHeader("Content-disposition", "attachment;filename=" + fileName);


        FileInputStream fileInputStream = null;
        try {
            fileInputStream = new FileInputStream(fileUrl);

            ServletOutputStream outputStream = response.getOutputStream();


            //
            byte[] buff = new byte[1024];

            int len;//读取有效的字节个数的长度
            while ((len = fileInputStream.read(buff)) != -1) {
                outputStream.write(buff, 0, len);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void downloadFiles(HttpServletResponse response,String fileName,String fileUrl,BufferedOutputStream bos,ZipOutputStream zos){






    }
}
